package com.base.service;

import java.util.*;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import tool.StringTool;
import tool.TimeTool;

import com.base.bean.*;
import com.base.dao.*;
import com.base.service.AddressService.ADD_TYPE;


/**
 * provinceId cityId areaId 空值替换为0 不如直接运行update语句更快
 * @author Administrator
 * @deprecated
 *
 */
public class SyncService2 {

	private volatile static SyncService2 instance = null;
	private ResultDao resultDao;
	private ClientBaseDao cbd;
	
	private SyncService2(){
		cbd = (ClientBaseDao) _BaseDao.ac.getBean("ClientBaseDao");
	}
	
	public static SyncService2 getInstance() {
		if (instance == null) {
			synchronized (SyncService2.class) {// 1
				if (instance == null) {// 2
					instance = new SyncService2();// 3
				}
			}
		}
		return instance;
	}
	
	
	
	
	
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SyncService2 ss=SyncService2.getInstance();
		
		for(int i=0;i<5000;i++){
			List<ClientBase> list=ss.getData(i*100,100);
			if(list.size()==0)
				break;
			for(ClientBase b:list){
				if(b.getProvinceId()==null)
					b.setProvinceId("0");
				if(b.getCityId()==null)
					b.setCityId("0");
				if(b.getAreaId()==null)
					b.setAreaId("0");
				ss.cbd.merge(b);
			}
			
			System.out.println("已处理"+i*100+"条");
		}
		
		System.out.println("END");
		
		
		
	}
	
	
	private List<ClientBase> getData(int offset,int pageSize){
		return cbd.findByPage("from ClientBase", offset, pageSize);
	}
	
	
	
	
	


}
